package com.naiterui.ehp.bp.enums;

/**
 * 是否枚举 全局  1是   0否
 * @author 胡超雄
 * @date 2021/4/2 10:20
 * @desc   0:社区, 1:楼宇, 2:单元, 3:层, 4:房间
 */
public enum BuildingTypeEnum {

    COMM(0, "社区"),
    BUILDING(1, "楼宇"),
    UNIT(2, "单元"),
    FLOOR(3, "层"),
    ROOM(4, "房间"),
    ;
    private Integer code;
    private String name;

    BuildingTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static BuildingTypeEnum getByCode(Integer code) {
        for (BuildingTypeEnum tmpEnum : values()) {
            if (tmpEnum.getCode().equals(code)) {
                return tmpEnum;
            }
        }
        return null;
    }

    /**
     * 转换枚举  如果是 0 回转成 1 .1回转成2 依次类推//4以上无法转换
     * @param code
     * @return
     */
    public static BuildingTypeEnum changeByCode(Integer code) {
        for (BuildingTypeEnum tmpEnum : values()) {
            if(tmpEnum.getCode().equals(code+1)){
                return tmpEnum;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
